{% extends "base.html" %}
{% block title %}
    学生成绩
{% endblock %}


{% block style %}

    .container-table {
    margin-top: 30px;
    }

{% endblock %}

{% block box %}
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                        aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">学生成绩查询</a>
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                {#                <ul class="nav navbar-nav">#}
                {#                    <li class="active"><a href="#">Home</a></li>#}
                {#                    <li><a href="#about">About</a></li>#}
                {#                    <li><a href="#contact">Contact</a></li>#}
                {#                </ul>#}

                <ul class="nav navbar-nav navbar-right">
                    {#                    <li><a href="../navbar/">Default</a></li>#}
                    <li><a href="">{{ request.session.username }}</a></li>
                    {#                    <li class="active"><a href="./">Static top <span class="sr-only">(current)</span></a></li>#}
                    <li><a href="/logout">退出</a></li>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </nav>
    <div class="container container-table">


        {% if  courses_score %}
            <div class="table-responsive">

                <table class="table table-bordered">
                    {#                {{ courses_score }}#}
                    <thead>
                    <tr>
                        <th>学生姓名</th>
                        <th>学生学号</th>
                        <th>考试课程</th>
                        <th>课程得分</th>
                        <th>考试学期</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for score in courses_score %}
                        <tr>
                            <th scope="row">{{ score.student.username }}</th>
                            <td>{{ score.student.uid }}</td>
                            <td>{{ score.course }}</td>
                            <td>{{ score.score }}</td>
                            <td>{{ score.semester }}</td>
                            {#                    <td>Table cell</td>#}
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        {% else %}
            <div class="container text-center">
                <h3>暂无成绩</h3>
            </div>
        {% endif %}
        <input type="hidden" value="{{ session_key }}" id="session">
    </div> <!-- /container -->
{% endblock %}

{% block feet %}
    <script src="//cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script>
        console.log($("#session").val());
        $.ajax({
            url: "/score",
            //跨域支持 begin
            xhrFields: {
                //携带cookie
                withCredentials: true
            },
            crossDomain: true,
            //跨域支持 end
            success: function (result) {
                {#console.log(result);#}
            },
            error: function () {
            }
        });
    </script>
{% endblock %}
